home *** CD-ROM | disk | FTP | other *** search
- class CitizenHandler
- {
- var location;
- var oHandler;
- var totalThresh;
- var aBobo;
- var baseThrust;
- var arcRange;
- var lowerArc;
- var oBuildings;
- var nRelease = 0;
- var cRelease = 0;
- var highThresh = 2;
- var lowThresh = 8;
- var levelInc = 0.3;
- var windChance = 3;
- var bBobo = false;
- var nTotalCitizens = 0;
- var nCitizenCap = 5;
- function CitizenHandler(loc)
- {
- this.location = loc;
- this.oHandler = new smashing.ClipHandler(loc);
- this.totalThresh = this.lowThresh - this.highThresh;
- this.aBobo = [loc._parent.mcBobo0,loc._parent.mcBobo1];
- this.aBobo[0].oCitizens = this;
- this.aBobo[1].oCitizens = this;
- this.baseThrust = new smashing.Point(-210,0);
- this.arcRange = 0.7853981633974483;
- this.lowerArc = 0.47123889803846897;
- }
- function update(nElapsed)
- {
- var _loc4_ = this.oHandler.clips;
- var _loc5_ = _loc4_.length;
- var _loc3_ = undefined;
- var _loc2_ = 0;
- while(_loc2_ < _loc5_)
- {
- _loc3_ = _loc4_[_loc2_];
- if(_loc3_ != null)
- {
- _loc3_.update(nElapsed);
- }
- _loc2_ = _loc2_ + 1;
- }
- this.cRelease += nElapsed;
- if(this.cRelease >= this.nRelease)
- {
- this.cRelease = 0;
- this.addCitizen();
- }
- }
- function render()
- {
- var _loc4_ = this.oHandler.clips;
- var _loc5_ = _loc4_.length;
- var _loc3_ = undefined;
- var _loc2_ = 0;
- while(_loc2_ < _loc5_)
- {
- _loc3_ = _loc4_[_loc2_];
- if(_loc3_ != null)
- {
- _loc3_.render();
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function addCitizen()
- {
- if(this.nTotalCitizens > this.nCitizenCap)
- {
- return undefined;
- }
- this.nTotalCitizens = this.nTotalCitizens + 1;
- var _loc2_ = this.aBobo[Number(this.bBobo)];
- if(_loc2_._currentframe == 1)
- {
- this.aBobo[Number(this.bBobo)].gotoAndStop("in");
- this.bBobo = !this.bBobo;
- }
- }
- function toss(pToss)
- {
- var _loc3_ = new smashing.Point(pToss.x - smashing.Viewport.centerX,pToss.y - smashing.Viewport.centerY);
- _loc3_.x += smashing.Viewport.x;
- _loc3_.y += smashing.Viewport.y;
- var _loc4_ = this.baseThrust.rotate(Math.random() * this.arcRange + this.lowerArc);
- var _loc2_ = this.oHandler.addClip("mcCitizen");
- _loc2_.x = _loc3_.x;
- _loc2_.y = _loc3_.y;
- _loc2_.m = _loc4_;
- _loc2_.oCitizenHandler = this;
- _loc2_.oBuildings = this.oBuildings;
- _loc2_.render();
- }
- function removeCitizen(o)
- {
- this.nTotalCitizens = this.nTotalCitizens - 1;
- this.oHandler.removeClip(o);
- }
- function setRatio(nRatio)
- {
- nRatio = 1 - nRatio;
- this.nRelease = nRatio * this.totalThresh + this.highThresh;
- }
- function reset()
- {
- this.oHandler.removeAllClips();
- }
- function setLevel(nLevel)
- {
- nLevel -= 1;
- this.totalThresh = this.lowThresh - this.highThresh - nLevel * this.levelInc;
- if(this.totalThresh < 0)
- {
- this.totalThresh = 0;
- }
- }
- }
-